<?php

include_once("util.php");
$name			= $_POST['name'];
$telephone		= $_POST['email'];
$address		= $_POST['email'];
$email			= $_POST['email'];
$content		= $_POST['content'];

if ($_POST['telephone'] && $_POST['address'])
{
	$subject	= "Online Ordering From Naibaifishball.com";
	$body		= "name : $name<br />
				   telephone : $telephone<br />
				   address : $address<br />
				   email : $email<br />
				   content : $content";
} else
{
	$subject	= "Question From Naibaifishball.com";
	$body		= "name : $name<br />
				   email : $email<br />
				   content : $content";
}

$err_msg = "";

if(strlen($err_msg) == 0)
{

	//$err_msg = $name;
	// send mail

	$mail             = new PHPMailer();

//	$body             = file_get_contents('contents.html');
//	$body             = eregi_replace("[\]",'',$body);
/*	$body			  = "name : $name<br />
						 email : $email<br />
						 content : $content";
*/
	$mail->IsSMTP(); // telling the class to use SMTP
	$mail->Host       = "mail.yourdomain.com"; // SMTP server
//	$mail->SMTPDebug  = 2;                     // enables SMTP debug information (for testing)
											   // 1 = errors and messages
											   // 2 = messages only
	$mail->SMTPAuth   = true;                  // enable SMTP authentication
	$mail->SMTPSecure = "ssl";                 // sets the prefix to the servier
	$mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
	$mail->Port       = 465;                   // set the SMTP port for the GMAIL server
	$mail->Username   = SUPPORT_EMAIL;  // GMAIL username
	$mail->Password   = SUPPORT_EMAIL_PASSWORD;            // GMAIL password

	$mail->SetFrom('no-reply@yourdomain.com', 'Naibaifishball');

//	$mail->AddReplyTo("no-reply@yourdomain.com","Naibaifishball");

	$mail->Subject    = $subject;

	$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test

	$mail->MsgHTML($body);

	$address = HOST_EMAIL;
	$mail->AddAddress($address);

	if(!$mail->Send()) 
	{
//		echo "Mailer Error: " . $mail->ErrorInfo;
//		$data_output['response_code'] = 0 ; // exist user & can send mail to user
//		$data_output['cus_id'] = $result['cus_id'] ;
//		echo json_encode($data_output);
		$err_msg = "can not send";
	} else 
	{
//		echo "Message sent!";
//		$data_output['response_code'] = 0 ; // exist user & can not send mail to user
//		$data_output['cus_id'] = $result['cus_id'] ;
//		echo json_encode($data_output);
	}
	
}

echo $err_msg;

 ?>